package com.yjk.dzpoke.websocket.bean;

import cn.hutool.json.JSONUtil;
import lombok.Data;

import java.util.List;

@Data
public class WsMsg {
    private Integer type;
    private String sender;
    private Object content;

    public static WsMsg heartBeat() {
        WsMsg wsMsg = new WsMsg();
        wsMsg.setType(heart_beat);
        return wsMsg;
    }

    public static WsMsg chatMsg(String sender, String msg) {
        WsMsg wsMsg = new WsMsg();
        wsMsg.setType(type_chat);
        wsMsg.setSender(sender);
        wsMsg.setContent(msg);
        return wsMsg;
    }

    public static WsMsg playersRoom(String msg) {
        WsMsg wsMsg = new WsMsg();
        wsMsg.setType(type_players_room);
        wsMsg.setContent(msg);
        return wsMsg;
    }

    public static WsMsg systemMsg(String msg) {
        WsMsg wsMsg = new WsMsg();
        wsMsg.setType(type_system);
        wsMsg.setContent(msg);
        return wsMsg;
    }

    public static WsMsg gameStart() {
        WsMsg wsMsg = new WsMsg();
        wsMsg.setType(game_start);
        return wsMsg;
    }

    public static WsMsg choice(Choice choice) {
        WsMsg wsMsg = new WsMsg();
        wsMsg.setType(game_choice);
        wsMsg.setContent(choice);
        return wsMsg;
    }

    public static WsMsg timer(Integer timer) {
        WsMsg wsMsg = new WsMsg();
        wsMsg.setType(game_timer);
        wsMsg.setContent(timer);
        return wsMsg;
    }

    public static WsMsg publicPoke(List<Poke> publicPoke) {
        WsMsg wsMsg = new WsMsg();
        wsMsg.setType(game_public_poke);
        wsMsg.setContent(publicPoke);
        return wsMsg;
    }

    public static WsMsg privatePoke(List<Poke> publicPoke) {
        WsMsg wsMsg = new WsMsg();
        wsMsg.setType(game_private_poke);
        wsMsg.setContent(publicPoke);
        return wsMsg;
    }


    @Override
    public String toString() {
        return JSONUtil.parse(this).toString();
    }

    //普通聊天信息
    public static final Integer heart_beat = 0;
    //普通聊天信息
    public static final Integer type_chat = 1;
    //大厅玩家
    public static final Integer type_players_room = 2;
    //游戏桌玩家
    public static final Integer type_players_table = 3;
    //系统提示
    public static final Integer type_system = 4;
    //游戏开始
    public static final Integer game_start = 5;
    //游戏结束
    public static final Integer game_end = 6;
    //游戏结束
    public static final Integer game_choice = 7;
    //公共牌
    public static final Integer game_public_poke = 8;
    //公共牌
    public static final Integer game_private_poke = 9;
    //计时器
    public static final Integer game_timer = 14;

}
